
package sclibrary.tela;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JRootPane;
import javax.swing.KeyStroke;

public class TelaEsc extends JDialog {
	@Override
	protected JRootPane createRootPane() {
		KeyStroke strokeEscape = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
		JRootPane rootPane = new JRootPane();
		rootPane.registerKeyboardAction(new ActionListener() {
			public void actionPerformed(ActionEvent actionEvent) {
				setVisible(false);
				dispose();
			}
		}, strokeEscape, JComponent.WHEN_IN_FOCUSED_WINDOW);
		return rootPane;
	}
}
